package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CoffeeShopStaff;
import com.ruoyi.system.service.ICoffeeShopStaffService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 店铺员工信息Controller
 * 
 * @author ruoyi
 * @date 2024-02-11
 */
@RestController
@RequestMapping("/system/staff")
public class CoffeeShopStaffController extends BaseController
{
    @Autowired
    private ICoffeeShopStaffService coffeeShopStaffService;

    /**
     * 查询店铺员工信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:staff:list')")
    @GetMapping("/list")
    public TableDataInfo list(CoffeeShopStaff coffeeShopStaff)
    {
        startPage();
        List<CoffeeShopStaff> list = coffeeShopStaffService.selectCoffeeShopStaffList(coffeeShopStaff);
        return getDataTable(list);
    }

    /**
     * 导出店铺员工信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:staff:export')")
    @Log(title = "店铺员工信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CoffeeShopStaff coffeeShopStaff)
    {
        List<CoffeeShopStaff> list = coffeeShopStaffService.selectCoffeeShopStaffList(coffeeShopStaff);
        ExcelUtil<CoffeeShopStaff> util = new ExcelUtil<CoffeeShopStaff>(CoffeeShopStaff.class);
        util.exportExcel(response, list, "店铺员工信息数据");
    }

    /**
     * 获取店铺员工信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:staff:query')")
    @GetMapping(value = "/{staffId}")
    public AjaxResult getInfo(@PathVariable("staffId") Long staffId)
    {
        return success(coffeeShopStaffService.selectCoffeeShopStaffByStaffId(staffId));
    }

    /**
     * 新增店铺员工信息
     */
    @PreAuthorize("@ss.hasPermi('system:staff:add')")
    @Log(title = "店铺员工信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CoffeeShopStaff coffeeShopStaff)
    {
        return toAjax(coffeeShopStaffService.insertCoffeeShopStaff(coffeeShopStaff));
    }

    /**
     * 修改店铺员工信息
     */
    @PreAuthorize("@ss.hasPermi('system:staff:edit')")
    @Log(title = "店铺员工信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CoffeeShopStaff coffeeShopStaff)
    {
        return toAjax(coffeeShopStaffService.updateCoffeeShopStaff(coffeeShopStaff));
    }

    /**
     * 删除店铺员工信息
     */
    @PreAuthorize("@ss.hasPermi('system:staff:remove')")
    @Log(title = "店铺员工信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{staffIds}")
    public AjaxResult remove(@PathVariable Long[] staffIds)
    {
        return toAjax(coffeeShopStaffService.deleteCoffeeShopStaffByStaffIds(staffIds));
    }
}
